package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GthBranchctrl;
import com.ruoyi.system.service.IGthBranchctrlService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 内联交易权限Controller
 * 
 * @author ruoyi
 * @date 2021-11-14
 */
@Controller
@RequestMapping("/system/branchctrl")
public class GthBranchctrlController extends BaseController
{
    private String prefix = "system/branchctrl";

    @Autowired
    private IGthBranchctrlService gthBranchctrlService;

    @RequiresPermissions("system:branchctrl:view")
    @GetMapping()
    public String branchctrl()
    {
        return prefix + "/branchctrl";
    }

    /**
     * 查询内联交易权限列表
     */
    @RequiresPermissions("system:branchctrl:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(GthBranchctrl gthBranchctrl)
    {
        startPage();
        List<GthBranchctrl> list = gthBranchctrlService.selectGthBranchctrlList(gthBranchctrl);
        return getDataTable(list);
    }

    /**
     * 导出内联交易权限列表
     */
    @RequiresPermissions("system:branchctrl:export")
    @Log(title = "内联交易权限", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(GthBranchctrl gthBranchctrl)
    {
        List<GthBranchctrl> list = gthBranchctrlService.selectGthBranchctrlList(gthBranchctrl);
        ExcelUtil<GthBranchctrl> util = new ExcelUtil<GthBranchctrl>(GthBranchctrl.class);
        return util.exportExcel(list, "内联交易权限数据");
    }

    /**
     * 新增内联交易权限
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存内联交易权限
     */
    @RequiresPermissions("system:branchctrl:add")
    @Log(title = "内联交易权限", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(GthBranchctrl gthBranchctrl)
    {
        return toAjax(gthBranchctrlService.insertGthBranchctrl(gthBranchctrl));
    }

    /**
     * 修改内联交易权限
     */
    @GetMapping("/edit/{logNo}")
    public String edit(@PathVariable("logNo") Long logNo, ModelMap mmap)
    {
        GthBranchctrl gthBranchctrl = gthBranchctrlService.selectGthBranchctrlByLogNo(logNo);
        mmap.put("gthBranchctrl", gthBranchctrl);
        return prefix + "/edit";
    }

    /**
     * 修改保存内联交易权限
     */
    @RequiresPermissions("system:branchctrl:edit")
    @Log(title = "内联交易权限", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(GthBranchctrl gthBranchctrl)
    {
        return toAjax(gthBranchctrlService.updateGthBranchctrl(gthBranchctrl));
    }

    /**
     * 删除内联交易权限
     */
    @RequiresPermissions("system:branchctrl:remove")
    @Log(title = "内联交易权限", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(gthBranchctrlService.deleteGthBranchctrlByLogNos(ids));
    }
}
